import _ from 'lodash';
import settings from './settings';
import { fastCloneDeep } from '../../../../src/utils';
import basicValues from './basicValues'

const values = basicValues;

const findMultipleValues = (valuesObj) => {
  const componentsWithMultipleValueSetting = {};
  _.each(valuesObj, (compPropertyValue, compKey) => {
    if(settings['multiple'][compKey]) {
      componentsWithMultipleValueSetting[compKey] = fastCloneDeep(compPropertyValue);
    }
  });
  return componentsWithMultipleValueSetting;
};

const multipleValues = _.mapValues(findMultipleValues(values), (value, compKey) => {
  if (compKey === 'select') {
    return ['a','b']
  }

  if (compKey === 'file') {
    const fileValue = fastCloneDeep(value);

    fileValue.push({
      name: "after-5c3e3b6b-c8b0-43c1-8cc5-cb4ede1e51cf.jpg",
      originalName: "after.jpg",
      size: 28473,
      storage: "base64",
      type: "image/jpeg",
      url: "",
    });

    return fileValue;
  }

  return [fastCloneDeep(value), fastCloneDeep(value)];
});

const stringValues = {
  form: '[Complex Data]',
  textField: 'test value',
  textArea: 'test value',
  number: '280',
  password: 'sOm_paSword123',
  checkbox: 'Yes',
  selectBoxes: 'a, c',
  select: '<span>A</span>',
  radio: 'b',
  email: 'user@example.com',
  url: 'https://portal.form.io',
  phoneNumber: '(555) 555-5555',
  tags: 'tag1',
  address: 'Dallas County, Texas, United States',
  dateTime: '2021-02-03 12:00 PM',
  day: '01/05/2005',
  time: '04:15',
  currency: '$30,000.00',
  survey: 'Question 1: yes; Question 2: no',
  numberColumn: '1111',
  textFieldColumn: 'value',
  numberFieldset: '222222',
  numberPanel: '66666',
  selectTable: '<span>one</span>',
  checkboxTable: 'Yes',
  dateTimeTable: '2031-02-03 05:00 AM',
  currencyTable: '$4,000.00',
  numberTab: '123456',
  textFieldTab: 'value',
  textFieldWell: 'value',
  hidden: 'hidden value',
  container: '[Complex Data]',
  dataMap: '[Complex Data]',
  dataGrid: '[Complex Data]',
  editGrid: '[Complex Data]',
  tree: '[Complex Data]',
  file: 'test file.docx',
  submit: 'true',
};

const submission =  {
  form: {
    data: {
    dataGridChild: [
      { textAreaInsideChildDataGrid: "test value in nested form1" },
      { textAreaInsideChildDataGrid: "test value in nested form2" }
    ],
    numberInsideChildPanel: 111111,
    textFieldChild: "test value in nested form",
    timeChild: "11:55:00",
    },
  },
  textField: 'test value',
  textArea: 'test value',
  number: 280,
  password: 'sOm_paSword123',
  checkbox: true,
  selectBoxes: { a: true, b: false, c: true },
  select: 'a',
  radio: 'b',
  email: 'user@example.com',
  url: 'https://portal.form.io',
  phoneNumber: '(555) 555-5555',
  tags: 'tag1',
  address: {
    address: { county: 'Dallas County', state: 'Texas', country: 'United States', country_code: 'us' },
    boundingbox: ['32.5453486', '32.9899027', '-97.0383833', '-96.5168819'],
    class: 'boundary',
    display_name: 'Dallas County, Texas, United States',
    icon: 'https://nominatim.openstreetmap.org/ui/mapicons//poi_boundary_administrative.p.20.png',
    importance: 0.6662149661993487,
    lat: '32.7620405',
    licence: 'Data © OpenStreetMap contributors, ODbL 1.0. https://osm.org/copyright',
    lon: '-96.7790069',
    osm_id: 1837698,
    osm_type: 'relation',
    place_id: 256774876,
    type: 'administrative',
  },
  dateTime: '2021-02-03T12:00:00',
  day: '01/05/2005',
  time: '04:15:00',
  currency: 30000,
  survey: {
    question1: 'yes',
    question2: 'no'
  },
  signature: '',
  numberColumn: 1111,
  textFieldColumn: 'value',
  numberFieldset: 222222,
  numberPanel: 66666 ,
  selectTable:'one',
  checkboxTable: true,
  dateTimeTable: '2031-02-03T05:00:00',
  currencyTable: 4000,
  numberTab: 123456,
  textFieldTab: 'value',
  textFieldWell: 'value',
  hidden: 'hidden value',
  container: { textFieldContainer: 'value1' },
  dataMap: { key: 'value1', key1: 'value2' },
  dataGrid: [
    { textFieldDataGrid: 'value1' },
    { textFieldDataGrid: 'value2' }
  ],
  editGrid: [{ textFieldEditGrid: 'value1' }, { textFieldEditGrid: 'value2' }],
  tree: {
    children: [{ children: [], data: {textFieldTree: 'value2'} }],
    data: { textFieldTree: 'value1' }
  },
  file: [{
    name: 'test file-15c248a4-401f-4456-aff9-abcbdf0f7bfa.docx',
    originalName: 'test file.docx',
    size: 11396,
    storage: 'base64',
    type: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
    url: 'data:application/vnd.openxmlformats-officedocument',
  }],
  submit: true,
};

export default { values, multipleValues, stringValues, submission };
